package com.easyidea.its.util;

import org.testng.annotations.Test;

import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FileTransferClient;

public class FTPClientUtilTest2 {

	@Test
	public void testGetRemoteFile2() {
		try {
			try {
				download("GB2312");
			} catch (Exception e) {
				e.printStackTrace();
				download("UTF-8");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void download(String encoding) throws Exception {

		FTPConfig config = new FTPConfig();
		config.setHost("pegvision.gicp.net");
		config.setUserName("test");
		config.setPassword("test");

		String host = config.getHost();
		String username = config.getUserName();
		String password = config.getPassword();


		FileTransferClient client = new FileTransferClient();
		client.setRemoteHost(host);
		client.setRemotePort(21);
		client.setUserName(username);
		client.setPassword(password);

		client.getAdvancedSettings().setControlEncoding(encoding);


		client.connect();
		client.setContentType(FTPTransferType.BINARY);
		client.changeDirectory("/文一路口/车道1/20100115/15/");

		client.downloadFile("d:/153300002_2.jpg", "153300002_2.jpg");
	}
}
